<include file="public:header"/>
<include file="public:sidebar"/>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            代理管理
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">代理</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="col-md-12">
            <div style="margin: 10px;">
                <button onclick="history.go(-1)" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-danger">
                    <i class="layui-icon">&#xe65c;</i>返回
                </button>
            </div>
            <!-- Horizontal Form -->
            <div class="box box-info">
                <div class="box-header with-border">
                    <h3 class="box-title">审核代理</h3>
                </div>
                <!-- /.box-header -->
                <!-- form start -->
                <form action="{:Url('mch/insert')}" method="post"
                      class="form-horizontal layui-form" autocomplete="off">
                    <div class="box-body">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">
                                <span class="text-danger">*</span>姓名
                            </label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control"
                                       placeholder="姓名" name="name"
                                       lay-verify="required"
                                 value="<notempty name='info'>{$info.name}</notempty>">
                                <input type="hidden" name="id"
                                       value="<notempty name='info'>{$info.id}</notempty>">
                                <input type="hidden" name="status" value="2">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">
                                <span class="text-danger">*</span>公司名
                            </label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control"
                                       placeholder="公司名" name="company"
                                       lay-verify="required"
                                       value="<notempty name='info'>{$info.company}</notempty>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">
                                联系电话
                            </label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control"
                                       name="tel"
                                       placeholder="联系电话"
                                       value="<notempty name='info'>{$info.tel}</notempty>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">
                               申请时间
                            </label>
                            <div class="col-sm-4">
                                <notempty name='info'>
                                    <input readonly type="text" class="form-control"
                                       value="{$info.create_time}" id="test1">
                                    <else/>
                                    <input readonly type="text" class="form-control"
                                           value="" id="test1">
                                </notempty>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">
                                <empty name='info'>是否通过<else/>状态</empty>
                            </label>
                            <div class="col-sm-10">
                                <empty name='info'>
                                    <div class="radio">
                                        <label>
                                            <input type="radio" <empty name='info'>checked<else/><eq name="info.status" value="2">checked</eq></empty> name="status" value="2">是
                                        </label>
                                        <label>
                                            <input type="radio" <notempty name="info"><eq name="info.status" value="3">checked</eq></notempty> name="status" value="3">否
                                        </label>
                                    </div>
                                    <else />
                                    <eq name="info.status" value="1">申请中</eq>
                                    <eq name="info.status" value="2">通过</eq>
                                    <eq name="info.status" value="3">失败</eq>
                                    <eq name="info.status" value="-1">禁用</eq>
                                </empty>
                            </div>
                        </div>
                        <if condition="$info eq '' and $info['status'] eq 1">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">
                                    操作
                                </label>
                                <div class="col-sm-4">
                                    <input type="checkbox" class="cross"
                                       lay-skin="switch"
                                       lay-text="通过|拒绝"  lay-filter="cross" checked>
                                    <textarea name="info" placeholder="请输入拒绝理由"
                                        class="layui-textarea" style="margin-top: 10px;display: none;"></textarea>
                                </div>
                            </div>
                        </if>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">
                            </label>
                            <div class="col-sm-4">
                                <button type="submit" class="btn btn-info" lay-submit lay-filter="*">确定</button>
                                <!--<button type="reset" class="btn btn-default">取消</button>-->
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </section>
    <!-- /.content -->
</div>
<style>
.layui-form-radio {
    line-height: 30px;
    margin: 0 0 0 0;
    padding-right: 0;
}
.layui-layer-shade{
    z-index: 99999;
}
.layui-layer-dialog{
    z-index: 999999;
}
.checkbox label, .radio label:first-child{
    padding-left: 0;
}
</style>
<script>
    layui.use(['form','layer','laydate'],function () {
        var form = layui.form,
            layer = layui.layer,
            laydate= layui.laydate;
        laydate.render({
            elem: '#test1',
            type: 'datetime'
        });
        form.on('switch(cross)', function(data){
            if(data.elem.checked){
                $('textarea[name="info"]').hide();
                $('input[name="status"]').val(2);
            }else {
                $('textarea[name="info"]').show();
                $('input[name="status"]').val(3)
            }
        });
        form.on('submit(*)', function(data){
            data.field.image = $('img.images').attr('src');
            $.post(data.form.action,data.field,function (result) {
                if(result.code){
                    layer.msg(result.msg);
                    return false;
                }
                layer.alert(result.msg,{icon:6,end:function () {
                    location.href = result.data.redirect;
                }});
            });
            return false;
        });
        $(document).on('click','.fa-close',function (e) {
            e.preventDefault();
            $('img.images').attr('src','');
            $('.show-image').hide();
        })
    });
</script>
<include file="public:footer"/>